<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let obj = {}
        obj.name = '张三' //正常赋值

        //defineProperty 从字面意思看就是定义属性
        Object.defineProperty(obj, 'age', {
            value: 20, //age键对应的默认值
            writable: true, //控制属性是否可修改  默认否false
            configurable: true, // 控制删除操作(是否可删除) 默认否false
            //enumerable: true //是否可以枚举(是否可以使用for..in 遍历) 默认false否
        })

        console.log(obj)

        for (const key in obj) {
            console.log(key)
        }
    </script>
</body>

</html>